#include "Sparks.h"

Sparks::Sparks(PlayerPosition pos, VisualObject* vObj, int x, int y):
	playerposition(pos),
	visualobject(vObj)
{
	representation = visualobject;
	if(pos == PP_RIGHT)
		representation->loadImage("images/sparksright.png");
	if(pos == PP_LEFT)
		representation->loadImage("images/sparksleft.png");
	
	timeAlive = 0;
	totalLifeTime = 0.05; // live for 0.1 sec
	canDie = false;

    this->x = x;
    this->y = y;
}

Sparks::~Sparks(void)
{
}

void Sparks::update(const double timePassed)
{
	timeAlive += timePassed;
	if(timeAlive > totalLifeTime)
		canDie = true;
}
void Sparks::getReadyForDraw()
{
    if(playerposition == PP_RIGHT)
	    representation->setOffsetX(x-getWidth());
    if(playerposition == PP_LEFT)
	    representation->setOffsetX(x);
	representation->setOffsetY(y-getHeight()/2);
}

bool Sparks::canBeDeleted()
{
	return canDie;

}

